package com.action;


import cn.hutool.core.util.RandomUtil;
import com.service.SendMailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SendMailAction {

    @Autowired
    private SendMailService sendMailService;

    /**
     * 发送邮件
     *
     * @param toMail
     * @return
     */
    @RequestMapping("/api/sendMail")
    public String sendMail(String toMail) {
        String code = RandomUtil.randomString(4);
        sendMailService.sendMail(toMail, "邮件注册验证码", code);
        return "success";
    }

    @RequestMapping("/api/yz")
    public String yz(String toMail,String code) {
        sendMailService.zset排行();
        sendMailService.nearPersion();
        String result = sendMailService.yz(toMail,code);
        return result;
    }
}
